package com.zscat.mallplus.center.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zscat.mallplus.center.BaseController;
import com.zscat.mallplus.center.entity.CenterColumnsRecommend;
import com.zscat.mallplus.center.service.ICenterColumnsRecommendService;
import com.zscat.mallplus.sys.entity.SysUser;
import com.zscat.mallplus.util.UserUtils;
import com.zscat.mallplus.utils.CommonResult;

/**
 * 栏目推荐Controller
 * 
 * @author Wsen
 * @date 2020-10-03
 */
@RestController
@RequestMapping("/centers/recommend")
public class CenterColumnsRecommendController extends BaseController {
	@Autowired
	private ICenterColumnsRecommendService centerColumnsRecommendService;

	/**
	 * 查询栏目推荐列表
	 */
//    @PreAuthorize("@ss.hasPermi('centers:recommend:list')")
	@GetMapping("/list")
	public Object list(CenterColumnsRecommend centerColumnsRecommend) {
		SysUser currentMember = UserUtils.getCurrentMember();
		  centerColumnsRecommend.setStoreId(currentMember.getStoreId().longValue());
		List<CenterColumnsRecommend> list = centerColumnsRecommendService
				.selectCenterColumnsRecommendList(centerColumnsRecommend);
		return new CommonResult().success(list);
	}

	/**
	 * 获取栏目推荐详细信息
	 */
//    @PreAuthorize("@ss.hasPermi('centers:recommend:query')")
	@GetMapping(value = "/{id}")
	public Object getInfo(@PathVariable("id") Long id) {
		return new CommonResult().success(centerColumnsRecommendService.selectCenterColumnsRecommendById(id));
	}

	/**
	 * 新增栏目推荐
	 */
//    @PreAuthorize("@ss.hasPermi('centers:recommend:add')")
	@PostMapping
	public Object add(@RequestBody CenterColumnsRecommend centerColumnsRecommend) {
		return new CommonResult()
				.success(centerColumnsRecommendService.insertCenterColumnsRecommend(centerColumnsRecommend));
	}

	/**
	 * 修改栏目推荐
	 */
//    @PreAuthorize("@ss.hasPermi('centers:recommend:update')")
	@PutMapping
	public Object edit(@RequestBody CenterColumnsRecommend centerColumnsRecommend) {
		return new CommonResult()
				.success(centerColumnsRecommendService.updateCenterColumnsRecommend(centerColumnsRecommend));
	}

	/**
	 * 删除栏目推荐
	 */
//    @PreAuthorize("@ss.hasPermi('centers:recommend:remove')")
	@DeleteMapping("/{ids}")
	public Object remove(@PathVariable Long[] ids) {
		return new CommonResult().success(centerColumnsRecommendService.deleteCenterColumnsRecommendByIds(ids));
	}
}
